<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ include file="/WEB-INF/jsp/include.jsp"%>
<script type="text/javascript">
    $(document).ready(function(){
        jQuery('.day_menu_in_jcrousel').each(function() {

            var userTableId = parseInt($(this).find(".userTableId").text());
            var dayMenuId = parseInt($(this).find(".dayMenuId").text());
            var dayNum = parseInt($(this).find(".dayNum").text());

            var menuOptions = [];
            if (dayMenuId > 0) {
                menuOptions = [
                    {title:"Открыть",
                        action:{
                            type:"fn0",
                            callback: function(){
                                post_to_url(
                                        "<c:url value="/daymenus-get.html" />",
                                        {
                                            usersTableId: userTableId,
                                            id: dayMenuId
                                        },
                                        "get"
                                );
                                return false;
                            }
                        }
                    },
                    {title:"Удалить",
                        action:{
                            type:"fn0",
                            callback: function(){
                                if (confirm('Вы действительно хотите удалить дневное меню?')) {
                                    post_to_url(
                                            "<c:url value="/daymenus-remove.html" />",
                                            {
                                                usersTableId: userTableId,
                                                id: dayMenuId
                                            },
                                            "post"
                                    );
                                }
                                return false;
                            }
                        }
                    }
                ];
            } else {
                menuOptions = [
                    {title:"Добавить",
                        action:{
                            type:"fn0",
                            callback: function(){
                                post_to_url(
                                        "<c:url value="/daymenus-add.html" />",
                                        {
                                            usersTableId: userTableId,
                                            dayNumber: dayNum
                                        },
                                        "post"
                                );
                                return false;
                            }
                        }
                    }
                ];
            }

            $(this).jjmenu(
                    "click",
                    menuOptions,
                    {},
                    //{show:"fadeIn", xposition:"left", yposition:"auto", "orientation":"corner"}
                    {show:"fadeIn", xposition:"mouse", yposition:"mouse"}
                    //{show:"slideDown",speed:400, yposition:"mouse", orientation:"mouse"}
            );
        });
    });
</script>
